define([
    'jquery',
    "comment"
], function ($, comment) {

    // 加载商品数据
    function goodsListDownload() {
        let baseUrl = comment.getBaseUrl();
        let categoryId = comment.valueByName(location.search, 'categoryId');//获取参数
        let page = 1; //当前的页码
        let pageSize = 10; //每页显示的数据条数
        let data = {
            categoryId,
            page,
            pageSize
        };
        $.get(baseUrl + "/goods/lists", data,
            function (res) {          
                console.log(res) 
                console.log(res.data);
                res.data.forEach(function (item, index) {
                    $(`<li>
                    <dl>
                        <dt><a href="goods.html?goodsId=${item.id}"><img src="${item.goodsThumb}" alt="" /></a></dt>
                        <dd><a href="">${item.goodsName}</a></dt>
                        <dd><strong>￥${item.shopPrice}</strong></dt>
                        <dd><a href=""><em>已有10人评价</em></a></dt>
                    </dl>
                </li>`).appendTo(".goodslist  ul");
                });


            }
        );

    }

    //分页
    function pageTab(){

    }






    return {
        goodsListDownload: goodsListDownload
    }

});